<html>
<head><meta charset="utf-8"><title>str_index · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html">str_index</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="177589866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177589866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177589866">(Oct 08 2019 at 07:24)</a>:</h4>
<p><span class="user-mention" data-user-id="201857">@Brendan Zabarauskas</span> , <span class="user-mention" data-user-id="132829">@Christopher Durham</span> let's move the codespan, text_unit conversation here :-)</p>



<a name="177590113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177590113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177590113">(Oct 08 2019 at 07:29)</a>:</h4>
<p>I have been wanting to make a breaking change to <code>text_unit</code> for some time (to get rid of inconsistent by-ref/by-value methods on <code>TextRange</code>, and of <code>of_str</code> ocamlism). I'll be totally up to replacing it with a new crate, if that crate has more than one designer (and I am totally willing to help out).</p>
<p>As I've written in discord:</p>
<ul>
<li>I suggest using <code>StrIndex</code>, <code>StrRange</code> terminology: it's short, it's about "how do you use it" and not "how do you implement it", and it's more <em>orthogonal</em>.</li>
<li>I am not sure if having a separate <code>StrOffset</code> makes sense. I would just trust <span class="user-mention" data-user-id="201857">@Brendan Zabarauskas</span> opinion here</li>
</ul>



<a name="177606660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177606660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177606660">(Oct 08 2019 at 12:09)</a>:</h4>
<p>Also, <span class="user-mention" data-user-id="201857">@Brendan Zabarauskas</span> what are your thoughts in general about splitting <code>codespan</code> into a indexin bit, and printing &amp; filemap bit?</p>
<p>The indexing part seems to be a micro crate, which is bad. However, at the same time it's also a "vocabulary type" and sits at the interface, and this seems like a good reason to keep it separate</p>



<a name="177619450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177619450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177619450">(Oct 08 2019 at 14:19)</a>:</h4>
<p>The purpose of the <code>Index</code>/<code>Offset</code> split IIUC is that <code>Offset</code> is a signed type (<code>i64</code>) suitable for arbitrary offsets</p>



<a name="177642187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177642187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177642187">(Oct 08 2019 at 18:07)</a>:</h4>
<p>I guess the TL;DR of it <span class="user-mention" data-user-id="201857">@Brendan Zabarauskas</span> is that I'd love to help with the move to merge annotate-snippets / codespan-reporting / langauge-reporting / text_unit</p>



<a name="177642282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177642282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177642282">(Oct 08 2019 at 18:08)</a>:</h4>
<p>Especially if the end result manages to nicely be bring-your-own DB and pluggable formatting engine</p>



<a name="177642345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177642345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177642345">(Oct 08 2019 at 18:08)</a>:</h4>
<p>(and, to clarify, <em>my</em> interest here is to extract a non-generic super-stupid crate with two types for better-than-usize indexing of strings)</p>



<a name="177642387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177642387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177642387">(Oct 08 2019 at 18:09)</a>:</h4>
<p>Which is definitely part of doing said merging</p>



<a name="177642481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177642481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177642481">(Oct 08 2019 at 18:10)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=beta&amp;mode=debug&amp;edition=2018&amp;gist=2d85dc44aec79acedcc0cdf4073895c8" target="_blank" title="https://play.rust-lang.org/?version=beta&amp;mode=debug&amp;edition=2018&amp;gist=2d85dc44aec79acedcc0cdf4073895c8">I did a play.rust-lang sketch of a unified API for StrIndex</a></p>



<a name="177642688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177642688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177642688">(Oct 08 2019 at 18:12)</a>:</h4>
<p><span class="user-mention" data-user-id="132829">@Christopher Durham</span> could you push that to a repo? I'd like to add a couple of comments :D</p>



<a name="177642932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177642932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177642932">(Oct 08 2019 at 18:15)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> &lt;<a href="https://github.com/CAD97/str-index/commit/b8fbc103fe8b0fadda08d5af94bf36a6603ef04d" target="_blank" title="https://github.com/CAD97/str-index/commit/b8fbc103fe8b0fadda08d5af94bf36a6603ef04d">https://github.com/CAD97/str-index/commit/b8fbc103fe8b0fadda08d5af94bf36a6603ef04d</a>&gt;</p>



<a name="177655760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177655760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177655760">(Oct 08 2019 at 20:29)</a>:</h4>
<p>OK, a decent baseline to review: <a href="https://github.com/CAD97/str-index/pull/1" target="_blank" title="https://github.com/CAD97/str-index/pull/1">https://github.com/CAD97/str-index/pull/1</a></p>



<a name="177757821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177757821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177757821">(Oct 09 2019 at 21:27)</a>:</h4>
<p>Sorry about the billion <code>force-with-lease</code> pushes, I'm trying (maybe too hard) to keep the commit history clean, and having branches PRing to a branch being adjusted is a recipe for a lot of rebasing.</p>



<a name="177767364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767364">(Oct 10 2019 at 00:02)</a>:</h4>
<p><span class="user-mention" data-user-id="132829">@Christopher Durham</span>  yeah, I've been curious about annotate-snippets too. I like how they completely remove the need for a file DB+indexing type</p>



<a name="177767380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767380">(Oct 10 2019 at 00:02)</a>:</h4>
<p>That was the direction I was actually hoping to move in with codespan.</p>



<a name="177767624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767624">(Oct 10 2019 at 00:07)</a>:</h4>
<p>The thing that has been preventing me from going all-in with <code>annotate-snippets</code> is:</p>
<p>- their use of <code>ansi_term</code> - which doesn't allow for injecting a custom coloured writer and relies on global state<br>
- how they try to stick close to rustc's error reporting style - I think we can make better use of box drawing characters, while also gracefully derading to ascii for those who need it</p>



<a name="177767823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767823">(Oct 10 2019 at 00:10)</a>:</h4>
<p>We _have_ been in discussions to see if we can get agreement for simplifying the ecosystem around <code>codespan</code>/<code>language-reporting</code>/<code>annotate-snippets</code>. So at least that's something!</p>



<a name="177767827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767827">(Oct 10 2019 at 00:10)</a>:</h4>
<p>rustc is moving towards using <code>annotate-snippets</code> IIRC (reminder: <a href="https://github.com/wycats/language-reporting/issues/6" target="_blank" title="https://github.com/wycats/language-reporting/issues/6">merge intension issue</a>)</p>



<a name="177767832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767832">(Oct 10 2019 at 00:10)</a>:</h4>
<p>Ohhh nice</p>



<a name="177767917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767917">(Oct 10 2019 at 00:12)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/59346" target="_blank" title="https://github.com/rust-lang/rust/issues/59346">rustc issue</a></p>



<a name="177767934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767934">(Oct 10 2019 at 00:12)</a>:</h4>
<p>Yeah Zibi, Yehuda, and I had a DM discussion on twitter about it a few months ago</p>



<a name="177767966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767966">(Oct 10 2019 at 00:13)</a>:</h4>
<p>So now's definitely the best time to consolidate efforts</p>



<a name="177767982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177767982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177767982">(Oct 10 2019 at 00:13)</a>:</h4>
<p>Yeah, tbh I would rather not have to maintain codespan if I don't need to</p>



<a name="177768054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768054">(Oct 10 2019 at 00:14)</a>:</h4>
<p>From the outside looking in it seems like building a new one by taking the good ideas from all three might be the best way forward (but I have I bias towards building things I'll admit)</p>



<a name="177768078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768078">(Oct 10 2019 at 00:15)</a>:</h4>
<p>Do you like anything about <code>codespan</code>? <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="177768157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768157">(Oct 10 2019 at 00:16)</a>:</h4>
<p>The name :P</p>



<a name="177768161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768161">(Oct 10 2019 at 00:16)</a>:</h4>
<p>hehehehe</p>



<a name="177768190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768190">(Oct 10 2019 at 00:17)</a>:</h4>
<p>I thought <code>language-reporting</code> was a nice name for the reporting side of things</p>



<a name="177768202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768202">(Oct 10 2019 at 00:17)</a>:</h4>
<p>The other thing I'd like some help on is how to integrate domain-specific diagnostics, like those in LALRPOP</p>



<a name="177768259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768259">(Oct 10 2019 at 00:18)</a>:</h4>
<p>And also allowing stuff like coloured type diffs and pretty printing, eg. <a href="https://github.com/Marwes/pretty.rs/" target="_blank" title="https://github.com/Marwes/pretty.rs/">https://github.com/Marwes/pretty.rs/</a></p>



<a name="177768303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768303">(Oct 10 2019 at 00:19)</a>:</h4>
<p>I think there's lots of cool scope to push beyond what rustc does. But perhaps if we joined forces we could improve rustc too.</p>



<a name="177768489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177768489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177768489">(Oct 10 2019 at 00:23)</a>:</h4>
<p>I had some ideas showing example output from different languages/tools: <a href="https://github.com/brendanzab/codespan/issues/1" target="_blank" title="https://github.com/brendanzab/codespan/issues/1">https://github.com/brendanzab/codespan/issues/1</a></p>



<a name="177782158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177782158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177782158">(Oct 10 2019 at 06:10)</a>:</h4>
<p>Note that <code>annotate_snippet</code> uses <code>usize</code> for indexing, and I think that's the <em>right</em> approach there. This is purely an <em>sink</em> layer, so optimizing storage with u32 does not makes sense, <em>and</em> because the user only feeds these types in, newtype wrapper benefits are also not that important. </p>
<p>This is in contrast to rowan, which both stores text unites, and is a <em>source</em> of text unites.</p>



<a name="177858085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177858085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Zabarauskas <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177858085">(Oct 10 2019 at 22:05)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> Yes, I agree. In hindsight I think the sink approach is a better design.</p>



<a name="177880660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177880660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177880660">(Oct 11 2019 at 06:04)</a>:</h4>
<p><span class="user-mention" data-user-id="132829">@Christopher Durham</span> what are your goals here? I feel that, if the lodestar is "unifying error reporting" crates, then <code>StrIndex</code> might not be on the right path then</p>



<a name="177919924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177919924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177919924">(Oct 11 2019 at 15:42)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> I think that my end goal is in fact "unifying error reporting", that said error reporting framework "seamlessly" translates from the "major" libraries for managing code span references, and that it can "render" to LSP (and no functionality of LSP is lost).</p>



<a name="177920181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177920181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177920181">(Oct 11 2019 at 15:45)</a>:</h4>
<p>Still, I think the experimentation done with <code>StrIndex</code> here can definitely serve to improve <code>text_unit</code></p>



<a name="177920428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177920428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177920428">(Oct 11 2019 at 15:48)</a>:</h4>
<p>Having played with annotate-snippets' <code>cleanup</code> branch a little, I think the "best" way forward seems to be building from there and bridging <code>codespan</code>/<code>language-reporting</code> to <code>annotate-snippets</code>.</p>



<a name="177920471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177920471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177920471">(Oct 11 2019 at 15:49)</a>:</h4>
<p>The exact point of concretizing spans for snippet annotation though is an interesting question</p>



<a name="177920651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177920651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177920651">(Oct 11 2019 at 15:50)</a>:</h4>
<p>In a "fork" of annotate-snippets I've delayed <code>Span</code> resolution all the way to printing with a <code>FnMut(Span, &amp;mut dyn WriteColor) -&gt; io::Result&lt;()&gt;</code> such that printing could include syntax highlighting</p>



<a name="177923713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/str_index/near/177923713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/str_index.html#177923713">(Oct 11 2019 at 16:25)</a>:</h4>
<p>I'm actually drafting an issue to propose the API surface I discovered with experimentation in said fork to <code>annotate-snippets</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>